const guestbookModel = require('../../model/guestbookModel');

const guestbookService = {
    add: async(data) => {
        return await guestbookModel.create({
            ...data,
            createTime: new Date()
        })
    },
    getList: async(skip,limit,userID) => {
        const data = await guestbookModel.find({userID}).sort({
            createTime: -1
        }).skip(skip).limit(limit);
        const total = await guestbookModel.countDocuments({userID});
        return {
            data,
            total
        }
    },
    getBullet:async(userID) => {
        const data = await guestbookModel.find({userID}).sort({
            createTime: -1
        })
        return data
    }
}

module.exports = guestbookService;